{% extends 'generic/object_detail.html' %}
{% load helpers %}

{% block extra_breadcrumbs %}
                {% if object.site %}
                    <li><a href="{% url 'ipam:vlan_list' %}?site={{ object.site.slug }}">{{ object.site }}</a></li>
                {% endif %}
                {% if object.group %}
                    <li><a href="{% url 'ipam:vlan_list' %}?group={{ object.group.slug }}">{{ object.group }}</a></li>
                {% endif %}
{% endblock extra_breadcrumbs %}

{% block extra_nav_tabs %}
        <li role="presentation"{% if active_tab == 'interfaces' %} class="active"{% endif %}>
            <a href="{% url 'ipam:vlan_interfaces' pk=object.pk %}">Device Interfaces <span class="badge">{{ object.get_interfaces.count }}</span></a>
        </li>
        <li role="presentation"{% if active_tab == 'vminterfaces' %} class="active"{% endif %}>
            <a href="{% url 'ipam:vlan_vminterfaces' pk=object.pk %}">VM Interfaces <span class="badge">{{ object.get_vminterfaces.count }}</span></a>
        </li>
{% endblock extra_nav_tabs %}

{% block content_left_page %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>VLAN</strong>
                </div>
                <table class="table table-hover panel-body attr-table">
                    <tr>
                        <td>Site</td>
                        <td>
                            {% if object.site %}
                                {% if object.site.region %}
                                    <a href="{{ object.site.region.get_absolute_url }}">{{ object.site.region }}</a> /
                                {% endif %}
                                <a href="{% url 'dcim:site' slug=object.site.slug %}">{{ object.site }}</a>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Group</td>
                        <td>
                            {% if object.group %}
                                <a href="{{ object.group.get_absolute_url }}">{{ object.group }}</a>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>VLAN ID</td>
                        <td>{{ object.vid }}</td>
                    </tr>
                    <tr>
                        <td>Name</td>
                        <td>{{ object.name }}</td>
                    </tr>
                    <tr>
                        <td>Tenant</td>
                        <td>
                            {% if object.tenant %}
                                {% if object.tenant.group %}
                                    <a href="{{ object.tenant.group.get_absolute_url }}">{{ object.tenant.group }}</a> /
                                {% endif %}
                                <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Status</td>
                        <td>
                            <span class="label" style="color: {{ object.status.color|fgcolor }}; background-color: #{{ object.status.color }}">{{ object.get_status_display }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td>Role</td>
                        <td>
                            {% if object.role %}
                                <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
                            {% else %}
                                <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Description</td>
                        <td>{{ object.description|placeholder }}</td>
                    </tr>
                </table>
            </div>
{% endblock content_left_page %}

{% block content_full_width_page %}
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>Prefixes</strong>
                </div>
                {% include 'responsive_table.html' with table=prefix_table %}
                {% if perms.ipam.add_prefix %}
                    <div class="panel-footer text-right noprint">
                        <a href="{% url 'ipam:prefix_add' %}?{% if object.tenant %}tenant={{ object.tenant.pk }}&{% endif %}site={{ object.site.pk }}&vlan={{ object.pk }}" class="btn btn-primary btn-xs">
                            <span class="mdi mdi-plus-thick" aria-hidden="true"></span>
                            Add a prefix
                        </a>
                    </div>
                {% endif %}
            </div>
{% endblock content_full_width_page %}
